var app = getApp()
Page({
  data: {
    domain:app.globalData.domain,
    System_Img_Url:app.globalData.System_Img_Url
  },


  onLoad: function () {
    this.Get_Collect_Album()
  },

//缓存搜索值
  formSubmit: function(e) {
    var search = e.detail.value.search.trim();
    this.setData({
      search:search,
    });
    this.Get_Collect_Album()
  },

//获取用户关注的公共相册
  Get_Collect_Album(){
    if(this.data.search){
      var search = this.data.search;
    }else{
      var search = "";
    }

    var t = this
    wx.request({
      url:app.globalData.urls,
      data:{
        GetTypes:'Get_Collect_Albums',
        openid:wx.getStorageSync('openid'),
        search:search
      },
      success:function(res){
        t.setData({
          album_info:res.data
        })
      }
    })
  },



//跳转到图片
//跳转到图片
  Jump_Pics(e){
    var album_id = e.currentTarget.dataset.album_id
    var album_name = e.currentTarget.dataset.album_name
    var album_cover = e.currentTarget.dataset.album_cover
    var album_flower = e.currentTarget.dataset.album_flower
    var album_collect = e.currentTarget.dataset.album_collect
    var album_openid = e.currentTarget.dataset.album_openid
    wx.navigateTo({
      url:'../pics/pics?album_id='+album_id+'&album_name='+album_name+'&album_cover='+album_cover+'&album_flower='+album_flower+'&album_collect='+album_collect+'&album_openid='+album_openid,
    })
  },

//点赞
  Zhan(e){
    var that = this
    wx.request({
      url:app.globalData.urls,
      data:{
        GetTypes:"Album_Flower_Add",
        Openid:wx.getStorageSync('openid'),
        Album_Id:e.currentTarget.dataset.aid
      },
      success:function(res){
        that.Get_Collect_Album()
      }

    })
  },





//收藏 
  Collect(e){
    var album_openid = e.currentTarget.dataset.openid
    var that = this
    wx.request({
      url:app.globalData.urls,
      data:{
        GetTypes:"Collect_Add",
        Openid:wx.getStorageSync('openid'),
        Album_Id:e.currentTarget.dataset.aid
      },
      success:function(res){
        that.Get_Collect_Album()
      }
    })

  },


  //顶部选项卡点击事件
  nav_hit(e){
    var t = this
    var nav_type = e.currentTarget.dataset.type
    if(nav_type=='album'){
      t.setData({
        nav_album:this.data.style_current,
        nav_author:this.data.style_other,
        album_hidden:false,
        author_hidden:true
      })
    }else{
      t.setData({
        nav_author:this.data.style_current,
        nav_album:this.data.style_other,
        album_hidden:true,
        author_hidden:false
      })
    }
  },


  Jump_Album(){
    wx.navigateTo({
      url:'../album_author/album_author'
    })
  }



})